How to add data in an empty dictionary in a function